version: '3'

services:
        bot_matrix:
                build: ./bot_matrix
                command: /readlaterbot/readlaterbot
                networks:
                        - app-network         
                restart: unless-stopped
                environment:
                        - TELEGRAM_BOT_TOKEN=${TELEGRAM_BOT_TOKEN_RELEASE}
                        - MATRIX_HOMESERVER_URL=${MATRIX_HOMESERVER_URL}
                        - MATRIX_USERNAME=${MATRIX_USERNAME}
                        - MATRIX_USER_ID=${MATRIX_USER_ID}
                        - MATRIX_PASSWORD=${MATRIX_PASSWORD}
                        - POSTGRES_URL=${POSTGRES_URL}
                        - POSTGRES_USER=${POSTGRES_USER}
                        - POSTGRES_DB=${POSTGRES_DB}
                        - RUST_BACKTRACE=full
                        - PROXY=${PROXY}
                volumes:
                        - matrix_bot_data:/readlaterbot/readlater_bot

                depends_on: 
                        - db
                        - mercury
                        - readability
                          
        bot_telegram:
                build: ./bot_telegram
                command: /readlaterbot/bot_telegram_bin
                networks:
                        - app-network         
                restart: unless-stopped
                environment:
                  #                        - TELEGRAM_BOT_TOKEN=${TELEGRAM_BOT_TOKEN}
                  #      - POSTGRES_URL=${POSTGRES_URL}
                  #      - POSTGRES_USER=${POSTGRES_USER}
                  #      - POSTGRES_DB=${POSTGRES_DB}
                        - RUST_BACKTRACE=full
                        - CONFIG_FILE=./config.toml
                          #      - PROXY=${PROXY}
                # volumes:
                #         - matrix_bot_data:/readlaterbot/readlater_bot

                depends_on: 
                        - db
                        - mercury
                        - readability
                ports:
                        - "6669:6669"
        db:
                image: postgres:15-alpine
                networks:
                        - app-network
                restart: unless-stopped
                ports:
                       - "5432:5432"
                environment:
                        - POSTGRES_DB=${POSTGRES_DB}
                       # - POSTGRES_HOST_AUTH_METHOD=trust
                        - POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
                volumes:
                        - postgres_data:/var/lib/postgresql/data
        mercury:
                #image: wangqiru/mercury-parser-api
                build: ../mercury-parser-api/
                restart: unless-stopped
                ports:
                        - "3000:3000"
                networks:
                        - app-network
        readability:
        #         image: phpdockerio/readability-js-server
                build: ../readability-js-server
                restart: unless-stopped
                ports:
                        - "3020:3020"
                networks:
                        - app-network
        article-extractor:
        #         image: phpdockerio/readability-js-server
                build: ../article-extractor-api
                restart: unless-stopped
                ports:
                        - "3010:3010"
                networks:
                        - app-network
networks:
  app-network:
    driver: bridge
volumes:
        postgres_data:
        matrix_bot_data:
